/* 
 * Copyright (C) 2008 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ss;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

import com.ss.R;


public class GetTickerActivity extends Activity
{  
        // UI elements
    Button mStartSearch;
    Spinner mMenuMode;
    EditText mQueryPrefill;
    EditText mQueryAppData;
    
        // Menu mode spinner choices
        // This list must match the list found in samples/ApiDemos/res/values/arrays.xml
    final static int MENUMODE_AUTOMATIC = 0;
    final static int MENUMODE_MENU_ITEM = 1;
    final static int MENUMODE_DISABLED = 2;
    
    /** 
     * Called with the activity is first created.
     * 
     *  We aren't doing anything special in this implementation, other than
     *  the usual activity setup code. 
     */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        
        // Inflate our UI from its XML layout description.
        showToast();
        setContentView(R.layout.get_ticker);
        
        // Get display items for later interaction
        mStartSearch = (Button) findViewById(R.id.btn_start_search);
       
        mQueryPrefill = (EditText) findViewById(R.id.txt_query_prefill);

        // Attach actions to buttons
        mStartSearch.setOnClickListener(
            new OnClickListener() {
                public void onClick(View v) {
                    onSearchRequested();
                }
            });
    }
    
   
    
    /**
     * This hook is called when the user signals the desire to start a search.
     * 
     * By overriding this hook we can insert local or context-specific data.
     * 
     * @return Returns true if search launched, false if activity blocks it
     */
    @Override
    public boolean onSearchRequested() {
        
        
        // It's possible to prefill the query string before launching the search
        // UI.  For this demo, we simply copy it from the user input field.
        // For most applications, you can simply pass null to startSearch() to
        // open the UI with an empty query string.
        final String queryPrefill = mQueryPrefill.getText().toString();
                 
        // Here we start the next activity, and then call finish()
        // so that our own will stop running and be removed from the
        // history stack.
        Intent intent = new Intent();
        intent.setClass(GetTickerActivity.this, ChartActivity.class);
        intent.putExtra("Ticker", queryPrefill);
        startActivity(intent);
        finish();
        
        // Returning true indicates that we did launch the search, instead of blocking it.
        return true;
    }
    
    public void showToast() 
    {
    	Context context=getApplicationContext();
    	String msg="In Get Ticker";
    	int duration= Toast.LENGTH_SHORT;
    	Toast toast=Toast.makeText(context, msg, duration);
    	toast.show();
    	
    	
    }
    
}
